import request from '@/utils/request'

// 获取排班列表
export function listSchedule(query) {
  return request({
    url: '/bussiness/scheduling/list',
    method: 'get',
    params: query
  })
}

// 获取警员列表
export function listOfficers(query) {
  return request({
    url: '/bussiness/officer/list',
    method: 'get',
    params: query
  })
}

// 获取班次列表
export function listShifts() {
  return request({
    url: '/system/shift/list',
    method: 'get'
  })
}

// 生成智能排班
export function generateSchedule(data) {
  return request({
    url: '/bussiness/scheduling/generate',
    method: 'post',
    data: data
  })
}

// 人工调整排班
export function adjustSchedule(data) {
  return request({
    url: '/bussiness/scheduling/person-adjust',
    method: 'post',
    data: data
  })
}

// 导出排班表
export function exportSchedule(query) {
  return request({
    url: '/bussiness/scheduling/export',
    method: 'get',
    params: query,
    responseType: 'blob'
  })
}

// 获取警员出勤统计
export function getOfficerAttendanceStats(officerId) {
  return request({
    url: '/bussiness/scheduling/stats/' + officerId,
    method: 'get'
  })
}

// 获取部门列表
export function listDepartments() {
  return request({
    url: '/system/dept/list',
    method: 'get'
  })
}

// 获取算法推荐参数
export function getAlgorithmRecommendParams() {
  return request({
    url: '/bussiness/scheduling/algorithm/params',
    method: 'get'
  })
}

/**
 * 根据勤务规划参数生成智能排班
 * @param {Object} params 勤务规划参数
 */
export function generateAISchedule(params) {
  return request({
    url: '/bussiness/scheduling/ai/generate',
    method: 'post',
    data: params
  })
}

/**
 * 删除排班记录
 * @param {Number|String} id 排班记录ID
 */
export function deleteSchedule(id) {
  return request({
    url: '/bussiness/scheduling/delete/' + id,
    method: 'delete'
  })
}
